package pl.umk.mat.fred.unicore.urc.storagemanagement.preferences;

import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.jface.viewers.CellEditor.LayoutData;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.eclipse.ui.PlatformUI;

import pl.umk.mat.fred.unicore.urc.storagemanagement.StorageManagementActivator;
import pl.umk.mat.fred.unicore.urc.storagemanagement.unicore.Storage;

public class PriorityPreferencePage	extends FieldEditorPreferencePage
									implements IWorkbenchPreferencePage {
	
	public PriorityPreferencePage() {
		super(GRID);
		setPreferenceStore(StorageManagementActivator.getDefault().getPreferenceStore());
		setDescription("If you set 0 value then a storage will be not used.");
		setMessage("Storage priority");
	}
	
	@Override
	public void init(IWorkbench arg0) {
	}

	@Override
	protected void createFieldEditors() {
		for (Storage storage : StorageManagementActivator.getDefault().getStorageList()) {
			IntegerFieldEditor priorityField = new IntegerFieldEditor(PreferenceConstants.P_PRIORITY_PREFIX + storage.getUrl(), storage.getName(), getFieldEditorParent());
			priorityField.setValidRange(0, 100);
			addField(priorityField);
		}
	}

}
